<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <div>
      <button onclick="doAxiosAjaxGet()">axios.get(...)</button>
      <button onclick="doAxiosAjaxPost()">axios.post(...)</button>
      <button onclick="doAxiosAjaxPostJSON()">axios.postJSON(...)</button>
  </div>
  <div class="result"></div>
  <script src="js/axios.min.js"></script>
  <script>
      function doAxiosAjaxPostJSON(){
          //1.url
          let url="http://localhost/doPostJSON";
          //2.params
          let params={"msg":"hello axios"};
          //3.send ajax post request
          //axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
          axios.post(url,params)
              .then(function(result){//callback function
                  console.log(result);
                  document.querySelector(".result").innerHTML=JSON.stringify(result.data);//原生的js代码
              })
              .catch(function (error) {
                  console.log(error);
              });

      }
      function doAxiosAjaxPost(){
          //1.url
          let url="http://localhost/doPost";
          //2.params
          let params="msg=hello axios";
          //3.send ajax post request
          //axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
          axios.post(url,params)
              .then(function(result){//callback function
                  console.log(result);
                  document.querySelector(".result").innerHTML=JSON.stringify(result.data);//原生的js代码
              })
              .catch(function (error) {
                  console.log(error);
              });

      }
      function doAxiosAjaxGet(){
          //1.url
          let url="http://localhost/doAjax";
          //2.params
          let params={params: {"msg":"hello axios"}}
          //3.send ajax get request
          axios.get(url,params)
               .then(function(result){//callback function
                   console.log(result);
                   document.querySelector(".result").innerHTML=JSON.stringify(result.data);//原生的js代码
               })
              .catch(function (error) {
                  console.log(error);
              });
      }

  </script>
</body>
</html>